home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 1087 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.4 KB

  1. Path: fido.asd.sgi.com!austern
  2. From: esap@cs.tut.fi (Pulkkinen Esa)
  3. Newsgroups: comp.std.c++
  4. Subject: Re: sample auto_ptr template
  5. Date: 15 Apr 1996 09:36:01 PDT
  6. Organization: Tampere University of Technology
  7. Approved: austern@isolde.mti.sgi.com
  8. Message-ID: <4kop9s$d8l@peippo.cs.tut.fi>
  9. References: <009A0A5CE1159CC0.49802F14@ittpub.nl> <gregorDpoGM2.Hw2@netcom.com> <4kjcvb$ghf@ugress.uib.no> <KANZE.96Apr12130738@gabi.gabi-soft.fr>
  10. NNTP-Posting-Host: isolde.mti.sgi.com
  11. X-Original-Date: 13 Apr 1996 17:46:36 GMT
  12. NNTP-Posting-User: esap
  13. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  14.     iQBVAwUBMXJ68ky4NqrwXLNJAQFzSQIAogLRJWVHxYA8wUYHbvcpbs3Vgcq5vkdW
  15.     xhtsmHViBAfbKbWPL2lLjoF3YqY3Si6ua2gLbkGMX4A1mfB7RbgwSw==
  16.     =Zv/9
  17. Originator: austern@isolde.mti.sgi.com
  18.  
  19. >In article <4kjcvb$ghf@ugress.uib.no> boukanov@sentef1.fi.uib.no (Igor
  20. >Boukanov) writes:
  21. >|> auto_ptr<T>(const auto_ptr<T>&) to auto_ptr<T>(auto_ptr<T>&)
  22. >|> and 
  23. >|> auto_ptr<T>& operator=(const auto_ptr<T>&) to
  24. >|> auto_ptr<T>& operator=(auto_ptr<T>&)
  25.  
  26. IMHO, copy constructors for auto_ptr must be either private or
  27. have non-const parameters.
  28.  
  29. In article <KANZE.96Apr12130738@gabi.gabi-soft.fr>,
  30. J. Kanze <kanze@gabi-soft.fr> wrote:
  31. >We've been through all this before.  That was the original version.
  32. >Regretfully, makes it impossible to return an auto_ptr from a function.
  33. >And one of the more frequent uses of auto_ptr involves returning them
  34. >from functions.
  35.  
  36. I can't really understand, why it should be possible to return
  37. auto_ptr's from functions - why not define a distinct pointer type
  38. for that purpose - and define conversion from auto_ptr to
  39. that pointer type for returning it from functions. That is - 
  40. to return an auto_ptr from functions, you write:
  41.  
  42.   taligent_ptr<T> f() 
  43.   { auto_ptr<T> p=new T;
  44.     return p;
  45.   }
  46.  
  47. (I have no idea if the 'taligent_ptr' is suitable for this kind of thing,
  48. but its name is as good as any for this example .... )
  49. -- 
  50.    Esa Pulkkinen                        | C++ programmers do it virtually
  51.    E-Mail:  esap@cs.tut.fi              | everywhere with a class, resulting
  52.    WWW   :  http://www.cs.tut.fi/~esap/ | in multiple inheritance.
  53. ---
  54. [ comp.std.c++ is moderated.  To submit articles: Try just posting with your 
  55.                 newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  56.   comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  57.   Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  58.   Comments? mailto:std-c++-request@ncar.ucar.edu 
  59. ]
  60.